<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			// let a = '111  222  333  666  444';
			// let b = a.startsWith('1');
			// let c = a.endsWith('2');
			// let d = a.repeat(4);
			// let e = a.padStart();
			
			// console.log(b);
			// console.log(c);
			// console.log(d);
			window.onload = function()
			{
				let btn = document.querySelector('button');
				let i = 0;
				let span = document.querySelector('span');
				let timer;
				btn.onclick = function()
				{
					if(btn.innerHTML == '开始计时')
					{
						timer = window.setInterval(function(){
							span.innerHTML = i;
							i++;
						}, 1000
						);
						btn.innerHTML = '暂停';
					}
					else
					{
						clearInterval(timer);
						btn.innerHTML = '开始计时'
					}
				}
			}
		</script>
	</head>
	<body>
		<button>开始计时</button>
		<span></span>
	</body>
</html>